package com.city.itis.action;

import java.util.List;
import org.apache.struts2.json.annotations.JSON;
import com.city.itis.domain.Site;
import com.city.itis.service.SiteService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * SiteMainAction
 * @author WY
 *
 */


public class SiteMainAction extends ActionSupport 
{
	private static final long serialVersionUID = 1L;	//系统自动生成的版本序列号
	
	private SiteService siteService=null;	//申明siteService对象
	
	private Integer categoryNo=0;	//定义整型变量categoryNo
	
	private double lat=0;	//定义双精度变量lat
	
	private double lng=0;	//定义双精度变量lng
	
	private double area=0;	//定义双精度变量area
	
	private List<Site> siteList=null;	//申明siteList对象
	
	private String result=null;	//定义字符串类型变量result
	
	
	/**
	 * 
	 * @return
	 * @throws Exception
	 */
	public String toMain() throws Exception
	{

		return "toMain";
	}
	
	/**
	 * 根据条件查询满足条件的站点信息
	 * @return
	 * @throws Exception
	 */
	public String toList() throws Exception
	{
		
		System.out.print("start");
		siteList=siteService.getListByCategoryAndPosition(categoryNo,lat,lng,area);
		System.out.println(lat);
		System.out.println(lng);
		for(Site s:siteList)
		{
			System.out.println(s.getSiteName());
			System.out.println(s.getCity());
		}
		System.out.println(lng);
		System.out.println(siteList.size());
		return "toList";
	}

	
	
	//以下都是Get和Set方法
	public SiteService getSiteService() {
		return siteService;
	}

	public void setSiteService(SiteService siteService) {
		this.siteService = siteService;
	}

	public Integer getCategoryNo() {
		return categoryNo;
	}

	public void setCategoryNo(Integer categoryNo) {
		this.categoryNo = categoryNo;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	public double getArea() {
		return area;
	}

	public void setArea(double area) {
		this.area = area;
	}
	@JSON(serialize = true)
	public List<Site> getSiteList() {
		return siteList;
	}

	public void setSiteList(List<Site> siteList) {
		this.siteList = siteList;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}
	
	
	
	

}
